// extends关键字，用途非常多

/**
 * 1.继承
 */

// class BasicUser{
//     private name:string;
//     private age:number;
// }

// class HeyiUser extends BasicUser{}

/**
 * 2.泛型约束
 */
interface BasicUser{
    name:string;
}
class UserBlock<UId,BU extends BasicUser>{
    private id:UId;
    private user:BU;
    constructor(id:UId,user:BU){
        this.id=id;
        this.user=user;
    }
    say(){
        this.id;
        this.user.name;
    }
}

/**
 * 3.条件类型
 */
type IsString<T>=T extends string?"yes":"no";

const age=18;
const heyiAge='18';
type heyiAgeType=IsString<typeof heyiAge>;


class Animal{
    name:string;
    constructor(name:string){
        this.name=name;
    }
    speak(){
        console.log(`${this.name} makes a sound`);
    }
}

class Dog extends Animal{
    constructor(name:string){
        super(name);
    }

}

const dog=new Dog("Buddy")
dog.speak();